package com.cxria.pattern.intermediary

class Stock extends AbstractColleague {

    Stock(AbstractMediator mediator) {
        super(mediator)
    }

    private static int COMPUTER_NUMBER = 100

    void increase(int number){
        COMPUTER_NUMBER += number
        println "库存数量为:${COMPUTER_NUMBER}"
    }

    void decrease(int number){
        COMPUTER_NUMBER -= number
        println "库存数量为:${COMPUTER_NUMBER}"
    }

    int getStockNumber(){
        COMPUTER_NUMBER
    }

    void clearStock(){
        println "清理库存数量为:${COMPUTER_NUMBER}"
        mediator.execute('stock.clear')
    }

}